package com.bokesoft.yigo.mid.service.example1;

import java.util.ArrayList;
import java.util.List;

import com.bokesoft.yigo.mid.condition.AbstractConditionBuilder;
/**
 * 此类用在Yigo_SteelFactoryExample项目的R_ProductData.xml中
 * @author ljd
 *
 */
public class RepairNumberQuery extends AbstractConditionBuilder {
	//构造sql
	@Override
	public String getFilter() {
		String value = this.paraTable.getValue("Repair_Number").toString();
		int size = value.split(";").length;
		
		String sql = "";
		if(size == 1) {
			sql = "repairnumber like ?";
		}else {
			for(int i = 0; i < size; ++i) {
				sql += ",?";
			}
			sql = "repairnumber in (" + sql.substring(1) + ")";
		}
		System.out.println(sql);
		return sql;
	}
	//构造参数
	@Override
	public List<Object> getParas() {
		List<Object> list = new ArrayList<>();
		String value = this.paraTable.getValue("Repair_Number").toString();
		String[] values = value.split(";");
		if(values.length==1) {
			list.add("%"+values[0]+"%");
		}else {
			for(String s:values) {
				list.add(s);
				System.out.println(s);
			}
		}
		return list;
	}

}
